<template>
  <a-row :gutter="10">
    <a-col :md="6" :sm="24">
      <a-card :bordered="false">
        <!-- 按钮操作区域 -->
        <a-row style="margin-left: 14px;">
          <a-button v-has="'category:add'" @click="handleAddCateGory(1)" type="primary">添加</a-button>
        </a-row>
        <div style="background: #fff;padding-left:16px;height: 100%; margin-top: 5px">
          <!--          <a-input-search @search="onSearch" style="width:100%;margin-top: 10px" placeholder="请输入单位名称" />-->
          <!-- 树-->
          <a-col :md="10" :sm="24">
            <template>
              <a-dropdown :trigger="[this.dropTrigger]" @visibleChange="dropStatus">
               <span style="user-select: none">
            <a-tree
              checkable
              multiple
              @select="onSelect"
              @check="onCheck"
              @rightClick="rightHandle"
              :selectedKeys="selectedKeys"
              :checkedKeys="checkedKeys"
              :treeData="departTree"
              :checkStrictly="checkStrictly"
              :expandedKeys="iExpandedKeys"
              :autoExpandParent="autoExpandParent"
              @expand="onExpand" />
                </span>
                <!--新增右键点击事件,和增加添加和删除功能-->
                <a-menu slot="overlay">
                  <a-menu-item v-has="'category:add'" @click="handleAddCateGory(2)" key="1">添加下级</a-menu-item>
                  <a-menu-item v-has="'category:edit'" @click="handleEditCateGory" key="2">编辑</a-menu-item>
                  <a-menu-item v-has="'category:del'" @click="handleDeleteCateGory" key="3">删除</a-menu-item>
                  <a-menu-item @click="closeDrop" key="4">取消</a-menu-item>
                </a-menu>
              </a-dropdown>
            </template>
          </a-col>
        </div>
      </a-card>
    </a-col>
    <a-col :md="18" :sm="24">
      <a-card :bordered="false">

        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
<!--              <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--                <a-form-item label="资产编码">-->
<!--                  <j-input placeholder="请输入资产编码" v-model="queryParam.assetCode"></j-input>-->
<!--                </a-form-item>-->
<!--              </a-col>-->
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="资产名称">
                  <j-input placeholder="请输入资产名称" v-model="queryParam.assetName"></j-input>
                </a-form-item>
              </a-col>
              <template v-if="toggleSearchStatus">
                <a-col :xl="6" :lg="7" :md="8" :sm="24">
                  <a-form-item label="坐落位置">
                    <j-input placeholder="请输入坐落位置" v-model="queryParam.site"></j-input>
                  </a-form-item>
                </a-col>
                <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
                <!--              <a-form-item label="管区">-->
                <!--                <j-dict-select-tag placeholder="请选择管区" :async="true" v-model="queryParam.regional" dictCode="zcgl_regional" />-->
                <!--              </a-form-item>-->
                <!--            </a-col>-->
<!--                <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--                  <a-form-item label="项目">-->
<!--                    <j-dict-select-tag placeholder="请选择项目" :async="true" v-model="queryParam.project"-->
<!--                                       dictCode="zcgl_project" />-->
<!--                  </a-form-item>-->
<!--                </a-col>-->
                <a-col :xl="6" :lg="7" :md="8" :sm="24">
                  <a-form-item label="取得方式">
                    <j-dict-select-tag placeholder="请选择取得方式" v-model="queryParam.assetClass"
                                       dictCode="zcgl_asset_classify" />
                  </a-form-item>
                </a-col>
<!--                <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--                  <a-form-item label="管理人员">-->
<!--                    <j-search-select-tag :async="true" placeholder="请选管理人员" v-model="queryParam.managerId"-->
<!--                                         dict="sys_user,realname,id" />-->
<!--                  </a-form-item>-->
<!--                </a-col>-->
                <a-col :xl="6" :lg="7" :md="8" :sm="24">
                  <a-form-item label="产权单位">
                    <j-input placeholder="请输入产权单位" v-model="queryParam.propertyRightUnit"></j-input>
                  </a-form-item>
                </a-col>
                <a-col :xl="6" :lg="7" :md="8" :sm="24">
                  <a-form-item label="产权证编号">
                    <j-input placeholder="请输入产权证编号" v-model="queryParam.propertyRightCode"></j-input>
                  </a-form-item>
                </a-col>
                <a-col :xl="6" :lg="7" :md="8" :sm="24">
                  <a-form-item label="状态">
                    <j-dict-select-tag placeholder="请选择状态" v-model="queryParam.status" dictCode="zcgl_asset_status" />
                  </a-form-item>
                </a-col>
                <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
                <!--              <a-form-item label="所属区域">-->
                <!--                <j-tree-select-->
                <!--                  v-model="queryParam.regionId"-->
                <!--                  placeholder="请选择区域"-->
                <!--                  dict="zcgl_region,region_name,id"-->
                <!--                  pidField="parent_id"-->
                <!--                  pidValue=""-->
                <!--                />-->
                <!--              </a-form-item>-->
                <!--            </a-col>-->

<!--                <a-col :xl="6" :lg="7" :md="8" :sm="24" v-is-group>-->
<!--                  <a-form-item label="所属公司">-->
<!--                    <j-company-select-tag placeholder="请选择所属公司" v-model="queryParam.companyId" />-->
<!--                  </a-form-item>-->
<!--                </a-col>-->
                <a-col :xl="6" :lg="7" :md="8" :sm="24">
                  <a-form-item label="具体情况">
                    <j-input placeholder="请输入具体情况" v-model="queryParam.concreteIssue"></j-input>
                  </a-form-item>
                </a-col>
                <!--<a-col :xl="6" :lg="7" :md="8" :sm="24">
                  <a-form-item label="土地性质">
                    <j-dict-select-tag placeholder="请选择土地性质" v-model="queryParam.landStatus"
                                       dictCode="zcgl_asset_soiltype"/>
                  </a-form-item>
                </a-col>
                <a-col :xl="6" :lg="7" :md="8" :sm="24">
                  <a-form-item label="房屋性质">
                    <j-dict-select-tag placeholder="请选择房屋性质" v-model="queryParam.roomType" dictCode="zcgl_asset_housetype"/>
                  </a-form-item>
                </a-col>-->
              </template>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <!-- 查询区域-END -->

        <!-- 操作按钮区域 -->
        <div class="table-operator">
          <a-button v-has="'assetInfo:add'" @click="handleAdd" type="primary" icon="plus">新增</a-button>
          <a-button v-has="'assetInfo:export'" type="primary" icon="download" @click="handleExportXls('资产信息')">导出
          </a-button>
          <a-button type="primary" icon="import" @click="handleImportExcelData">导入</a-button>
          <a-button v-has="'assetInfo:temp'" type="primary" icon="download" @click="handleExportXlsTemplate('资产信息模板')">
            模板下载
          </a-button>
          <!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
          <!--        <a-menu slot="overlay">-->
          <!--          <a-menu-item key="1" @click="batchDel">-->
          <!--            <a-icon type="delete"/>-->
          <!--            删除-->
          <!--          </a-menu-item>-->
          <!--        </a-menu>-->
          <!--        <a-button style="margin-left: 8px"> 批量操作-->
          <!--          <a-icon type="down"/>-->
          <!--        </a-button>-->
          <!--      </a-dropdown>-->
        </div>

        <!-- table区域-begin -->
        <div>
          <!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
          <!--        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{-->
          <!--        selectedRowKeys.length }}</a>项-->
          <!--        <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
          <!--      </div>-->

          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :scroll="{ x: 5000, y: screenHeight }"
            class="j-table-force-wrap"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            @change="handleTableChange">
            <!--        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"-->

            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
              <img v-else :src="getImgView(text)" height="25px" alt=""
                   style="max-width:80px;font-size: 12px;font-style: italic;" />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
              <a-button
                v-else
                :ghost="true"
                type="primary"
                icon="download"
                size="small"
                @click="uploadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
          <!--<a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />-->
          <a v-has="'assetInfo:look'" @click="handleDetail(record)">查看</a>
          <template v-if="record.status == 1 && isApproval == 1">

            <a-divider v-has="'assetInfo:look'" type="vertical" />
            <a v-has="'assetInfo:add'"
               v-if="record.processStatus != 2 && record.processStatus != 1 && record.processStatus != 0"
               @click="handleEdit(record)">
              编辑
            </a>

            <a-divider v-if="record.processStatus != 2 && record.processStatus != 1 && record.processStatus != 0"
                       type="vertical" />
            <a v-has="'assetInfo:add'" @click="modifyForm(record, '生效审批')">
              生效审批
            </a>

          </template>
          <template v-else-if="record.status != 40">
            <a-divider v-has="'assetInfo:look'" type="vertical" />
            <a-dropdown>
              <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
              <a-menu slot="overlay">

                <template v-if="isApproval == 1">
                  <a-menu-item v-if="record.processStatus == 2" v-has="'assetInfo:edit'">
                    <a @click="handleEdit(record)">编辑</a>
                  </a-menu-item>
                  <a-menu-item v-else v-has="'assetInfo:edit'">
                    <a @click="modifyForm(record,'变更审批')">变更审批</a>
                  </a-menu-item>
                </template>
                <template v-else>
                  <a-menu-item v-has="'assetInfo:edit'">
                    <a @click="handleEdit(record)">编辑</a>
                  </a-menu-item>
                </template>

                <a-menu-item v-has="'assetInfo:disposal'">
                  <a @click="assetDisposal(record)">处置</a>
                </a-menu-item>
                <!--              <span>-->
                  <a-menu-item v-has="'assetInfo:delete'" v-if="record.status == 10">
                    <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                      <a>删除</a>
                    </a-popconfirm>
                </a-menu-item>
                <!--              </span>-->
              </a-menu>
            </a-dropdown>
          </template>
        </span>

          </a-table>
        </div>

        <assetInfo-modal ref="modalForm" @ok="modalFormOk"></assetInfo-modal>
        <assetInfoDisposal-modal ref="modalDisposalForm" @ok="modalDisposalOk"></assetInfoDisposal-modal>
        <asset-category-modal ref="assetCategoryModal" @ok="modalFormOk"></asset-category-modal>
        <!--流程表单-->
        <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="80%">
          <component :disabled="lcModa.disabled" v-if="lcModa.visible" :is="lcModa.formComponent"
                     :processData="lcModa.processData" :isNew="lcModa.isNew"
                     @afterSubmit="processFormOk" @close="lcModa.visible=false, lcModa.disabled = false"></component>
        </a-modal>



        <a-modal title="资产分离" ref="reasonModal" :visible="aavisible" @ok="handleReasonOk" @cancel="handleReasonCancel">
          <a-form :form="form">
            <a-form-item label="资产分类" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-select-asset-category v-decorator="['assetType']" @change="assetTypeChange"></j-select-asset-category>
            </a-form-item>
              <a-upload v-has="'assetInfo:import'" name="file" :showUploadList="false" :multiple="false"
                        :headers="tokenHeader"
                        :action="importExcelUrl"
                        @change="handleImportExcel">
                <a-button type="primary" icon="import">导入</a-button>
              </a-upload>
          </a-form>

        </a-modal>
      </a-card>
    </a-col>
  </a-row>


</template>

<script>

import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import AssetInfoModal from './modules/AssetInfoModal'
import AssetInfoDisposalModal from './modules/AssetInfoDisposalModal'
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
import JInput from '@/components/jeecg/JInput'
import '@/assets/less/TableExpand.less'
import { activitiMixin } from '@views/activiti/mixins/activitiMixin'
import { mixinDevice } from '@/utils/mixin'
import JSearchSelectTag from '@comp/dict/JSearchSelectTag'
import JTreeSelect from '@comp/jeecg/JTreeSelect'
import JCompanySelectTag from '@comp/jeecg/JCompanySelectTag'
import JTreeTable from '@/components/jeecg/JTreeTable'
import { getAction, deleteAction } from '@/api/manage'
import AssetCategoryModal from './modules/AssetCategoryModal'
import JSelectAssetCategory from '../../components/jeecgbiz/JSelectAssetCategory'

export default {
  name: 'AssetInfoList',
  mixins: [activitiMixin, JeecgListMixin, mixinDevice],
  components: {
    JInput,
    JDictSelectTag,
    AssetInfoDisposalModal,
    JSearchSelectTag,
    JCompanySelectTag,
    JTreeSelect,
    AssetInfoModal,
    JTreeTable,
    AssetCategoryModal,
    JSelectAssetCategory
  },
  data () {
    return {
      description: '资产信息管理页面',
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          fixed: 'left',
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.ipagination.current - 1) * this.ipagination.pageSize + index + 1}`
        },
        {
          title: '资产名称',
          align: 'center',
          width: 180,
          fixed: 'left',
          dataIndex: 'assetName'
        },
        {
          title: '产权证编号',
          align: 'center',
          width: 180,
          dataIndex: 'propertyRightCode'
        },
        // {
        //   title: '原产权证号',
        //   align: 'center',
        //   dataIndex: 'formerPropertyRight'
        // },
        {
          title: '坐落位置',
          align: 'center',
          width: 200,
          dataIndex: 'site'
        },
        {
          title: '土地面积(亩)',
          align: 'center',
          width: 180,
          dataIndex: 'landArea'
        },
        {
          title: '土地面积(平方)',
          align: 'center',
          width: 180,
          dataIndex: 'landAreaSquare'
        },
        {
          title: '评估入账金(万元)',
          align: 'center',
          width: 180,
          dataIndex: 'evaluateFees'
        },
        {
          title: '土地用途',
          align: 'center',
          width: 180,
          dataIndex: 'landUse'
        },
        {
          title: '土地等级',
          align: 'center',
          width: 180,
          dataIndex: 'landLevel'
        },
        {
          title: '抵押情况',
          align: 'center',
          width: 180,
          dataIndex: 'mortgageSituation'
        },
        {
          title: '取得方式',
          align: 'center',
          width: 180,
          dataIndex: 'assetClass_dictText'
        },
        {
          title: '资产类型',
          align: 'center',
          width: 180,
          dataIndex: 'assetType_dictText'
        },
        {
          title: '资产名称',
          align: 'center',
          width: 180,
          dataIndex: 'assetName'
        },
        {
          title: '产权单位',
          align: 'center',
          width: 180,
          dataIndex: 'propertyRightUnit'
        },

        // {
        //   title: '所属区域',
        //   align: 'center',
        //   dataIndex: 'regionId_dictText'
        // },
        // {
        //   title: '商户名称',
        //   align: 'center',
        //   dataIndex: 'merchantName'
        // },
        {
          title: '状态',
          align: 'center',
          width: 180,
          dataIndex: 'status_dictText',
          customRender: function (t, r, index) {
            if (r.status == 40) {
              return t + '（' + r.assetDisposal_dictText + '：' + r.assetDisposalDate + '：' + r.assetDisposalDescription + '）'
            }
            return t
          }
          // render: (text, record) => ({
          //   if({record.status == 10}){
          //
          //   }
          // })
        },
        // {
        //   title: '管理人员',
        //   align: 'center',
        //   dataIndex: 'managerId_dictText'
        // },

        // {
        //   title: '楼层',
        //   align: 'center',
        //   dataIndex: 'floorNumber'
        // },
        {
          title: '建成年份',
          align: 'center',
          width: 180,
          dataIndex: 'buildTime'
        },
        {
          title: '结构',
          align: 'center',
          width: 180,
          dataIndex: 'houseStructure'
        },
        // {
        //   title: '房屋用途',
        //   align: 'center',
        //   dataIndex: 'houseUse'
        // },
        {
          title: '土地权利性质',
          align: 'center',
          width: 180,
          dataIndex: 'landAuthorityNature'
        },
        // {
        //   title: '出让终止日期',
        //   align: 'center',
        //   dataIndex: 'toSellEndtime',
        //   customRender: function (text) {
        //     return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
        //   }
        // },
        // {
        //   title: '取得日期',
        //   align: 'center',
        //   dataIndex: 'getTime',
        //   customRender: function (text) {
        //     return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
        //   }
        // },
        // {
        //   title: '产权面积（m²）',
        //   align: 'center',
        //   dataIndex: 'propertyRightArea'
        // },
        {
          title: '建筑面积（m²）',
          align: 'center',
          width: 180,
          dataIndex: 'coveredArea'
        },
        // {
        //   title: '出租面积（m²）',
        //   align: 'center',
        //   dataIndex: 'landUseArea'
        // },
        // {
        //   title: '土地性质',
        //   align: 'center',
        //   dataIndex: 'landStatus_dictText'
        // },
        {
          title: '房屋性质',
          width: 180,
          align: 'center',
          dataIndex: 'roomType_dictText'
        },
        // {
        //   title: '价值（万元）',
        //   align: 'center',
        //   dataIndex: 'worth'
        // },
        // {
        //   title: '空置原因',
        //   align: 'center',
        //   dataIndex: 'emptyReason'
        // },
        // {
        //   title: '具体问题',
        //   align: 'center',
        //   dataIndex: 'concreteIssue'
        // },
        // {
        //   title: '是否有产权',
        //   align: 'center',
        //   dataIndex: 'isProperty_dictText'
        // },
        {
          title: '管区',
          width: 180,
          align: 'center',
          dataIndex: 'regional_dictText'
        },
        // {
        //   title: '项目',
        //   align: 'center',
        //   dataIndex: 'project_dictText'
        // },
        // {
        //   title: '原管理单位',
        //   align: 'center',
        //   dataIndex: 'originalManagementUnit'
        // },
        // {
        //   title: '原产权单位',
        //   align: 'center',
        //   dataIndex: 'originalPropertyRightUnit'
        // },
        // {
        //   title: '批复文号',
        //   align: 'center',
        //   dataIndex: 'approvalDocumentNumber'
        // },
        // {
        //   title: '调拔时间',
        //   align: 'center',
        //   dataIndex: 'pullTime'
        // },
        // {
        //   title: '产权证地址',
        //   align: 'center',
        //   dataIndex: 'addressPropertyDivision'
        // },
        // {
        //   title: '经营情况',
        //   align: 'center',
        //   dataIndex: 'businessCircumstance'
        // },
        // {
        //   title: '接收时间',
        //   align: 'center',
        //   dataIndex: 'receiptTime',
        //   customRender: function (text) {
        //     return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
        //   }
        // },
        // {
        //   title: '接收类型',
        //   align: 'center',
        //   dataIndex: 'receiptType'
        // },
        // {
        //   title: '管理单位',
        //   align: 'center',
        //   dataIndex: 'managementUnitId_dictText'
        // },
        // {
        //   title: '权利类型',
        //   align: 'center',
        //   dataIndex: 'landAuthorityType_dictText'
        // },
        // {
        //   title: '权籍情况',
        //   align: 'center',
        //   dataIndex: 'rightCitizenshipSituation_dictText'
        // },
        // {
        //   title: '权属情况',
        //   align: 'center',
        //   dataIndex: 'ownershipSituation_dictText'
        // },
        // {
        //   title: '使用权人名称',
        //   align: 'center',
        //   dataIndex: 'holderRightName'
        // },
        // {
        //   title: '使用权证号',
        //   align: 'center',
        //   dataIndex: 'licenseNumber'
        // },
        // {
        //   title: '收款税率',
        //   align: 'center',
        //   dataIndex: 'collectionRate'
        // },
        // {
        //   title: '是否抵押',
        //   align: 'center',
        //   dataIndex: 'izMortgage_dictText'
        // },

        {
          title: '共有面积(平方)',
          align: 'center',
          width: 180,
          dataIndex: 'totalArea'
        },
        // {
        //   title: '房屋面积m²',
        //   align: 'center',
        //   children: [
        //     // {
        //     //   title: '住宅面积',
        //     //   align: 'center',
        //     //   dataIndex: 'residentialArea'
        //     // },
        //     // {
        //     //   title: '非住宅面积',
        //     //   align: 'center',
        //     //   dataIndex: 'nonResidentialArea'
        //     // },
        //     // {
        //     //   title: '门市面积',
        //     //   align: 'center',
        //     //   dataIndex: 'outletsArea'
        //     // }
        //   ]
        // },

        {
          title: '总库容(万立方米)',
          align: 'center',
          dataIndex: 'totalCapacity'
        },
        {
          title: '土地类型',
          align: 'center',
          dataIndex: 'landType'
        },
        {
          title: '套内面积',
          align: 'center',
          dataIndex: 'insideArea'
        },
        {
          title: '入账价值(万元)',
          align: 'center',
          dataIndex: 'entryValue'
        },
        // {
        //   title: '年租金',
        //   align: 'center',
        //   dataIndex: 'rentYear'
        // },
        {
          title: '车位数',
          align: 'center',
          dataIndex: 'parkingSpaceNumber'
        },

        // {
        //   title: '栋号',
        //   align: 'center',
        //   dataIndex: 'movieTheater'
        // },
        // {
        //   title: '原栋号',
        //   align: 'center',
        //   dataIndex: 'oldMovieTheater'
        // },
        // {
        //   title: '视觉楼层',
        //   align: 'center',
        //   dataIndex: 'visualFloor'
        // },
        // {
        //   title: '房号',
        //   align: 'center',
        //   dataIndex: 'roomNumber'
        // },
        // {
        //   title: '挂牌面积',
        //   align: 'center',
        //   dataIndex: 'tradingArea'
        // },
        {
          title: '处置户型',
          align: 'center',
          dataIndex: 'disposalRoom'
        },
        {
          title: '处置方式',
          align: 'center',
          dataIndex: 'disposalType'
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'remark'
        },
        {
          title: '附件',
          align: 'center',
          dataIndex: 'accessory',
          scopedSlots: { customRender: 'fileSlot' }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 200,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/zcgl/assetInfo/list',
        delete: '/zcgl/assetInfo/delete',
        deleteBatch: '/zcgl/assetInfo/deleteBatch',
        exportXlsUrl: '/zcgl/assetInfo/exportXls',
        importExcelUrl: 'zcgl/assetInfo/importExcel',
        exportXlsTemplate: 'zcgl/assetInfo/exportXlsTemplate'
      },
      dictOptions: {},
      currSelected: {},
      dropTrigger: '',
      selectedKeys: [],
      checkedKeys: [],
      departTree: [],
      checkStrictly: true,
      iExpandedKeys: [],
      autoExpandParent: true,
      rightClickSelectedKey: '',
      rightClickSelectedModel: '',
      categoryModel: {},
      form: this.$form.createForm(this),
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      aavisible: false,
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    // initDictConfig () {
    //   this.addColumns()
    // },
    assetDisposal (record) {
      this.$refs.modalDisposalForm.show(record)
    },
    modalDisposalOk () {
      this.loadData()
    },
    modifyForm (r, name, type) {
      let tableData = {
        routeName: '@/views/activiti/form/AssetModify',
        tableName: 'zcgl_asset_info',
        tableId: r.id
      }
      if (type == 1) {
        tableData.routeName = '@/views/activiti/form/AssetAdd'
      }
      this.processCreateCom(tableData, '发起资产' + name + '流程', r.processStatus)
    },
    handleAdd: function () {
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    },
    loadData (arg) {
      this.refresh()
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams()//查询条件
      this.loading = true
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
          this.ipagination.total = res.result.total
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
      })
    },
    loadTree () {
      var that = this
      that.treeData = []
      that.departTree = []
      getAction('/zcgl/assetCategory/queryTreeList').then((res) => {
        if (res.success) {
          //部门全选后，再添加部门，选中数量增多
          this.allTreeKeys = []
          for (let i = 0; i < res.result.length; i++) {
            let temp = res.result[i]
            that.treeData.push(temp)
            // if (temp.orgCategory == 0){
            if (!temp.parentId || temp.parentId == 0) {
              temp.disableCheckbox = true
              temp.selectable = true
              // temp.disabled = true;
            }
            that.departTree.push(temp)
            that.setThisExpandedKeys(temp)
          }
          that.departTree.push( that.departTree[0])
          that.departTree.splice(0, 1)
          this.loading = false
        }
      })
    },
    setThisExpandedKeys (node) {
      if (node.children && node.children.length > 0) {
        this.iExpandedKeys.push(node.key)
        for (let a = 0; a < node.children.length; a++) {
          this.setThisExpandedKeys(node.children[a])
        }
      }
    },
    refresh () {
      this.loading = true
      this.loadTree()
    },
    // 右键点击下拉框改变事件
    dropStatus (visible) {
      if (visible == false) {
        this.dropTrigger = ''
      }
    },
    onCheck (checkedKeys, info) {
      this.hiding = false
      //this.checkedKeys = checkedKeys.checked
      // <!---- author:os_chengtgen -- date:20190827 --  for:切换父子勾选模式 =======------>
      if (this.checkStrictly) {
        this.checkedKeys = checkedKeys.checked
      } else {
        this.checkedKeys = checkedKeys
      }
      // <!---- author:os_chengtgen -- date:20190827 --  for:切换父子勾选模式 =======------>
    },
    onSelect (selectedKeys, e) {
      this.hiding = false
      let record = e.node.dataRef
      this.currSelected = Object.assign({}, record)
      this.assetCategoryModal = this.currSelected
      this.selectedKeys = [record.key]
      this.assetCategoryModal.parentId = record.parentId

      this.queryParam.assetType = record.id
      this.loadData()
    },
    // 右键操作方法
    rightHandle (node) {
      this.dropTrigger = 'contextmenu'
      console.log(node.node.eventKey)
      this.rightClickSelectedKey = node.node.eventKey
      this.rightClickSelectedModel = node.node.dataRef
    },
    onExpand (expandedKeys) {
      console.log('onExpand', expandedKeys)
      // if not set autoExpandParent to false, if children expanded, parent can not collapse.
      // or, you can remove all expanded children keys.
      this.iExpandedKeys = expandedKeys
      this.autoExpandParent = false
    },
    // 右键店家下拉关闭下拉框
    closeDrop () {
      this.dropTrigger = ''
    },
    handleAddCateGory (mark) {
      console.log('mark', mark)
      if (mark === 2) {
        console.log('this.rightClickSelectedModel', this.rightClickSelectedModel)
        this.$refs.assetCategoryModal.parentId = this.rightClickSelectedModel.id
        this.$refs.assetCategoryModal.level = parseInt(this.rightClickSelectedModel.level) + 1
      } else if (mark === 1) {
        console.log('bbbbbbb')
        this.$refs.assetCategoryModal.parentId = 0
        this.$refs.assetCategoryModal.level = 1
      }
      this.$refs.assetCategoryModal.visible = true
      this.$refs.assetCategoryModal.add()
    },
    handleEditCateGory () {
      this.$refs.assetCategoryModal.parentId = this.rightClickSelectedModel.parentId
      this.$refs.assetCategoryModal.level = this.rightClickSelectedModel.level
      this.$refs.assetCategoryModal.edit(this.rightClickSelectedModel)
      this.$refs.assetCategoryModal.title = '编辑'
      this.$refs.assetCategoryModal.disableSubmit = false
    },
    handleDeleteCateGory () {
      let that = this
      deleteAction('/zcgl/assetCategory/delete', { id: this.rightClickSelectedModel.id }).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.loadData()
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    assetTypeChange(e){
      this.url.importExcelUrl = 'zcgl/assetInfo/importExcel?assetType='+e;
    },
    /* 导入 */
    handleImportExcelData (info) {
      this.aavisible = true
    },
    handleReasonOk () {
      this.aavisible = false
    },
    handleReasonCancel () {
      this.aavisible = false
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>